import { createStore } from 'vuex'



import user from './user'

import cart from './cart'

import { CHANGEMONEY } from './mutation-types'



const state = {
    msg: 'vuex 你好',
    money: 100,
}

const mutations = {
    CHANGEMONEY (state) {
        state.money += 100
    },

    // changeMoney:function () {

    // }

    // function changeMoney() {}


}


const actions = {
    asyncChangeMoney (context) {
        setTimeout(() => {
            context.commit(CHANGEMONEY)
        }, 1000)
    }

}

const getters = {
    doubleMoney (state) {
        return state.money * 10
    }

}


const store = createStore({
    state,
    mutations,
    getters,
    actions,
    modules: {
        user,
        cart
    }
})


export default store